module.exports = function ($scope, $resource, $modal, toaster, getDate) {

	//加载游团列表
	$scope.getTravelList = function() {
		$scope.searchform.loading = true;
		var para = {
			'company_code': $scope.searchform.company_code,
			'status': $scope.searchform.status,
			'period': $scope.searchform.period,
			'group_name': $scope.searchform.group_name,
			'arrive_place': $scope.searchform.arrive_place,
		}
		$resource('/api/as/goc/outboundtravel/getCountList', {}, {}).save(para, function(res){
            if (res.errcode === 0) {
				$scope.list = res.data;
				$scope.searchform.loading = false;
            } else {
                toaster.error({title: '', body: '查询出境游信息失败'});
            }
        });
	}

	//查询全部已参加出境游的机构列表
	$scope.loadCompanyList = function(){
		$resource('/api/as/goc/companyapply/getCompanyCodeList', {}, {}).save({}, function(res){
			if (res.errcode === 0) {
				$scope.company_list = res.data;
				$scope.company_list.unshift({'company_name': '全部', 'company_code': null});
			}
		});
	}
	
	init();
	function init() {
		$scope.searchform = {
			'status': '',
			'statusList': [
				{'label': '全部', 'value': ''},
				{'label': '未上报', 'value': '0'},
				{'label': '审核中', 'value': '1'},
				{'label': '已通过', 'value': '2'},
				{'label': '未通过', 'value': '3'},
			]
		};
		$scope.dictTravel = {
			'a0': '未上报',
			'a1': '审核中',
			'a2': '已通过',
			'a3': '未通过',
		};
		$scope.loadCompanyList();
		$scope.getTravelList();
	}

	$scope.getInfo = function(info){
		var modalInstance = $modal.open({
			template: require('../views/travelInfo.html'),
			controller: 'travelInfo',
			size: 'lg',
			resolve: {
				travel: function () {
					return info;
				},
				checkFlag: function () {
					return false;
				}
			}
		});
	}


	$scope.grouplist = function(item){
		var modalInstance = $modal.open({
			template: require('../views/grouplist.html'),
			controller: 'grouplist',
			size: 'lg',
			resolve: {
				travel: function () {
					return item;
				}
			}
		});
	}


};